package JDBC;

import java.sql.*;
import java.util.concurrent.Callable;

public class Example03 {
    private String dbDriver ="com.mysql.cj.jdbc.Driver";
    private String dbUrl ="jdbc:mysql://127.0.0.1:3306/bookmanager?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai";
    private String dbUserName ="root";
    private String dbPassword ="新的密码";
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Example03 e1 = new Example03();
        Class.forName(e1.dbDriver);
        Connection co = DriverManager.getConnection(e1.dbUrl,e1.dbUserName,e1.dbPassword);
        String sql="SELECT *FROM user";
        Statement stm = co.createStatement();
        ResultSet rs=stm.executeQuery(sql);
        while (rs.next()){
            int id=rs.getInt("id");
            String username=rs.getString("username");
            String password=rs.getString("password");
            int role=rs.getInt("role");
            String sex=rs.getString("sex");
            String phone=rs.getString("phone");
            System.out.println(id+"|"+username+"|"+password+"|"+role+"|"+sex+"|"+phone);
        }
    }
}
